#include "friendlabel.h"
#include "ui_friendlabel.h"
#include <QDebug>

FriendLabel::FriendLabel(QWidget *parent) :
    QFrame(parent),
    ui(new Ui::FriendLabel)
{
    ui->setupUi(this);
//    ui->label->SetState("normal","hover","pressed",
//                              "selected_normal","selected_hover","selected_pressed");
    //ui->close_label;
    //connect(ui->close_label)
}

FriendLabel::~FriendLabel()
{
    delete ui;
}

void FriendLabel::SetText(QString text)
{
    _text = text;
    ui->tip_label->setText(_text);
    ui->tip_label->adjustSize();
    QFontMetrics fontMerics(ui->tip_label->font());//获取QLabel控件的字体信息
    int textWidth = fontMerics.width(ui->tip_label->text());//获取文本的宽度
    int textHeight = fontMerics.height();//获取文本的高度
    qDebug()<<" ui->tip_label.width() is "<<ui->tip_label->width();
    qDebug()<<" ui->close_label->width() is "<<ui->close_label->width();
    qDebug()<<" textWidth is "<<textWidth;
    this->setFixedWidth(ui->tip_label->width()+ui->close_label->width()+5);
    this->setFixedHeight(textHeight+2);
    qDebug()<<" this->setFixedHeight "<<this->height();
    _width = this->width();
    _height = this->height();
}

int FriendLabel::Width()
{
    return _width;
}

int FriendLabel::Height()
{
    return _height;
}

QString FriendLabel::Text()
{
    return _text;
}

void FriendLabel::slot_close()
{

}
